package it.trio.monopoly.fitnesse;

import it.trio.monopoly.domain.FakeDieWithFixedSequenceSeed;
import it.trio.monopoly.domain.MGame;
import it.trio.monopoly.util.FakeTerminalThatStoresMessage;

public class PlayGame {
	private Integer rounds;
	private Integer players;
	public void setPlayers(Integer players) {
		this.players = players;
	}

	private String diceTotal;
	private Integer roundCount;

	public PlayGame() {
	}
	  
	public void setRounds(Integer rounds) {
		this.rounds = rounds;
	}

	// removes last comma and add parenthesys
	private String beautify(String s) {
		return "("+s.subSequence(0, s.length()-1)+")";
	}
	
	public Integer roundCount() {
		FakeTerminalThatStoresMessage terminal = new FakeTerminalThatStoresMessage();
		MGame game = new MGame(terminal);

		game.startPlay(rounds, players);
		roundCount = game.getRoundsCount();
		
		return roundCount;
	}
	
	public String diceTotal() {
		FakeTerminalThatStoresMessage terminal = new FakeTerminalThatStoresMessage();
		MGame game = new MGame(terminal, new FakeDieWithFixedSequenceSeed(), new FakeDieWithFixedSequenceSeed());

		game.startPlay(rounds, players);
		diceTotal = beautify(terminal.getMessage());

		return diceTotal;
	  }
} 
